﻿Imports System.Data.SqlClient
Public Class BaoCaoF

    Public Function QuyetToanTh(ByVal SoQt As String) As DataTable
        Dim myProjCnn As New ProjectConnection
        Dim myCnn As New SqlConnection
        Dim myDat As New SqlDataAdapter
        Dim myDtb As New DataTable

        myCnn = myProjCnn.GetConnection
        myCnn.Open()

        Dim myCmd As New SqlCommand
        With myCmd
            .Connection = myCnn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "Bc_QuyetToanTh"

            .Parameters.Add(New SqlClient.SqlParameter("@soqt", SqlDbType.Char))
            .Parameters("@soqt").Value = SoQt

        End With

        myDat = New SqlDataAdapter(myCmd)
        myDat.Fill(myDtb)
        Return myDtb
        myCnn.Close()
    End Function

    Public Function QuyetToanCt(ByVal SoQt As String, ByVal Doan As String) As Boolean
        Dim myProjCnn As New ProjectConnection
        Dim myCnn As New SqlConnection
        Dim myDat As New SqlDataAdapter
        Dim myDtb As New DataTable

        myCnn = myProjCnn.GetConnection
        myCnn.Open()

        Dim myCmd As New SqlCommand
        With myCmd
            .Connection = myCnn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "Bc_QuyetToanCt" + Doan

            .Parameters.Add(New SqlClient.SqlParameter("@soqt", SqlDbType.Char))
            .Parameters("@soqt").Value = SoQt

            .Parameters.Add(New SqlClient.SqlParameter("@return", SqlDbType.Bit)).Direction = ParameterDirection.ReturnValue
            .ExecuteNonQuery()
        End With

        If myCmd.Parameters("@return").Value = 1 Then
            myCnn.Close()
            myCnn.Dispose()
            Return True
        Else
            myCnn.Close()
            myCnn.Dispose()
            Return False
        End If
    End Function

    Public Function QuyetToanCt_Get(ByVal SoQt As String) As DataTable
        Dim myProjCnn As New ProjectConnection
        Dim myCnn As New SqlConnection
        Dim myDat As New SqlDataAdapter
        Dim myDtb As New DataTable

        myCnn = myProjCnn.GetConnection
        myCnn.Open()

        Dim myCmd As New SqlCommand
        With myCmd
            .Connection = myCnn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "Bc_QuyetToanCt_Get"

            .Parameters.Add(New SqlClient.SqlParameter("@soqt", SqlDbType.Char))
            .Parameters("@soqt").Value = SoQt

        End With

        myDat = New SqlDataAdapter(myCmd)
        myDat.Fill(myDtb)
        Return myDtb
        myCnn.Close()
    End Function

End Class


